package dfs;

import entity.tree.Node;

import java.util.ArrayList;
import java.util.List;

public class leetcode590N叉树的后序遍历 {
    public List<Integer> postorder(Node root) {
        List<Integer> list = new ArrayList<>();
        if (root == null) {
            return list;
        } else {
            int size = root.children.size();
            for (int i = 0; i < size; i++) {
                list.addAll(postorder(root.children.get(i)));
            }
            list.add(root.val);
            return list;
        }
    }
}
